package main.java.exception;

import java.io.FileOutputStream;
import java.io.IOException;

public class AutoCloseableDemo {
    public static void main(String[] args) {
        try(
                //只有实现了AutoCloseable接口的类才可以用try(){}
                //所有的流都实现了AutoCloseable接口
                FileOutputStream fos = new FileOutputStream("E:\\51_home-work\\homework\\src\\main\\resource\\test.txt")
        ){
            fos.write(97);
        }catch (IOException e){
            System.out.println("出错了");
        }
    }
}
